package com.GroupG.GTools.example;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Tag(name = "HelloController")
public class PersonController {
    @GetMapping("/hello2")
    public String hello2() {
        return "hello world v3";
    }

    @Operation(summary = "测试登录的接口",
            description = "描述的文字",
            responses = {
                    @ApiResponse(description = "登录信息",
                            content = @Content(mediaType = "application/json",
                                    schema = @Schema(implementation = Person.class))),
                    @ApiResponse(responseCode = "400", description = "返回400时候错误的原因")},
            security = @SecurityRequirement(name = "需要认证"))
    @GetMapping("/login")
    public Person login(
            @Parameter(description = "姓")
            @RequestParam(value = "firstName", required = false) String firstName,
            @Parameter(description = "名")
            @RequestParam(value = "lastName") String lastName) {
        Person userModel = new Person();
        userModel.setFirstName(firstName);
        userModel.setLastName(lastName);
        return userModel;
    }
}
